using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using TimeTableManagement.Entities;

namespace TimeTableManagement.Mapping
{
	public class Tb_UserloginMap : EntityTypeConfiguration<Tb_Userlogin>
	{
		public Tb_UserloginMap()
		{
			// Primary Key
			this.HasKey(t => t.id);

			// Properties
			this.Property(t => t.username)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.password)
				.IsRequired();
				
			this.Property(t => t.displayname)
				.HasMaxLength(255);
				
			this.Property(t => t.email)
				.HasMaxLength(255);
				
			// Table & Column Mappings
			this.ToTable("Tb_Userlogin");
			this.Property(t => t.id).HasColumnName("id");
			this.Property(t => t.username).HasColumnName("username");
			this.Property(t => t.password).HasColumnName("password");
			this.Property(t => t.id_role).HasColumnName("id_role");
			this.Property(t => t.rememberme).HasColumnName("rememberme");
			this.Property(t => t.displayname).HasColumnName("displayname");
			this.Property(t => t.email).HasColumnName("email");

			// Relationships
			this.HasRequired(t => t.Tb_Role)
				.WithMany(t => t.Tb_Userlogin)
				.HasForeignKey(d => d.id_role);
				
		}
	}
}

